package com.example.myproject.domain;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@ConfigurationProperties(prefix = "student")
public class Student {

    private String stdId;
    private String stdName;
    private List<String> hobby;

    @PostConstruct
    public void init() {
        System.out.println("stdId: " + stdId);
        System.out.println("stdName: " + stdName);
        System.out.println("hobby: " + hobby);
    }
    // 添加 Getter 和 Setter 方法

    public String getStdId() {
        return stdId;
    }

    public void setStdId(String stdId) {
        this.stdId = stdId;
    }

    public String getStdName() {
        return stdName;
    }

    public void setStdName(String stdName) {
        this.stdName = stdName;
    }

    public List<String> getHobby() {
        return hobby;
    }

    public void setHobby(List<String> hobby) {
        this.hobby = hobby;
    }

    // toString 方法@Override
    //public String toString() {
    //    return "{\n" +
    //            "  \"stdId\": \"" + stdId + "\",\n" +
    //            "  \"stdName\": \"" + stdName + "\",\n" +
    //            "  \"hobby\": [" + String.join(", ", hobby) + "]\n" +
    //            "}";
    //}
    @Override
    public String toString() {
        return "{\n" +
                "  \"stdId\": \"" + stdId + "\",\n" +
                "  \"stdName\": \"" + stdName + "\",\n" +
                "  \"hobby\": [" + String.join(", ", hobby) + "]\n" +
                "}";
    }
}
